package com.da.service;

import com.da.beans.Employee;
import com.da.mappers.EmpMapper;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class EmpService {
    @Autowired
    private EmpMapper empMapper;

    public Employee selectOne(Employee employeeQBC) {
        return empMapper.selectOne(employeeQBC);
    }

    public Employee getEmployeeById(Integer empId) {
        return empMapper.selectByPrimaryKey(empId);
    }

    public List<Employee> select(Employee employeeQBC) {
        return empMapper.select(employeeQBC);
    }

    public boolean isExists(Integer empId) {
        return empMapper.existsWithPrimaryKey(empId);
    }

    public void saveEmployee(Employee employee) {
        empMapper.insert(employee);
    }

    public void saveEmpSelective(Employee employee) {
        empMapper.insertSelective(employee);
    }

    public void updateEmployeeSelective(Employee employee) {
        empMapper.updateByPrimaryKeySelective(employee);
    }

    public void removeEmployee(Employee employee) {
        empMapper.delete(employee);
    }

    public void removeEmployeeById(Integer empId) {
        empMapper.deleteByExample(empId);
    }

    public List<Employee> getEmpListByExample(Example example) {
        return empMapper.selectByExample(example);
    }

    public List<Employee> getEmpListByRowBounds(RowBounds rowBounds) {
        return empMapper.selectByRowBounds(null, rowBounds);
    }
}
